package net.j4love.spring.mvc.ex.model;

import org.hibernate.validator.constraints.NotBlank;

import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.math.BigDecimal;

/**
 * @author He Peng
 * @create 2017-06-13 23:21
 * @update 2017-06-13 23:21
 * @updatedesc : 更新说明
 * @see
 */
public class User {

    private Long id;

    @NotBlank(message = "姓名不能为空")
    private String name;

    @NotNull(message = "手机号码不能为空")
    @Min(
            value = 10000000000L,
            message = "手机号长度不合法"
    )
    @Max(
            value = 99999999999L,
            message = "手机号长度不合法"
    )
//    @Pattern(
//            regexp = "^[1][3,4,5,7,8][0-9]{9}$",
//            message = "手机号码格式不合法"
//    )
    private Long phone;

    @NotNull(message = "年龄不能为空")
    @Min(0)
    private Short age;

    private String gender;

    @Valid
    @NotNull
    private Hobby hobby;

    @NotNull(message = "decimal不能为null")
    private BigDecimal decimal;

    public Hobby getHobby() {
        return hobby;
    }

    public User setHobby(Hobby hobby) {
        this.hobby = hobby;
        return this;
    }

    public String getGender() {
        return gender;
    }

    public User setGender(String gender) {
        this.gender = gender;
        return this;
    }

    public Long getId() {
        return id;
    }

    public User setId(Long id) {
        this.id = id;
        return this;
    }

    public String getName() {
        return name;
    }

    public User setName(String name) {
        this.name = name;
        return this;
    }

    public Long getPhone() {
        return phone;
    }

    public User setPhone(Long phone) {
        this.phone = phone;
        return this;
    }

    public Short getAge() {
        return age;
    }

    public User setAge(Short age) {
        this.age = age;
        return this;
    }

    public BigDecimal getDecimal() {
        return decimal;
    }

    public User setDecimal(BigDecimal decimal) {
        this.decimal = decimal;
        return this;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", phone=" + phone +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                ", hobby=" + hobby +
                ", decimal=" + decimal +
                '}';
    }
}
